<%--
  Created by IntelliJ IDEA.
  User: abwan
  Date: 2020/12/20
  Time: 14:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <style>
        div{
            margin-top: 30px;
        }
    </style>
    <title>数据库表查询</title>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.0/dist/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">

    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.0/dist/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>

</head>
<body>
<%--<c:if test="${tableName == 'student'}">
    <table border="1">
        <tr>
            <th>学号</th>
            <th>姓名</th>
            <th>性别</th>
            <th>邮箱</th>
        </tr>
        <c:forEach items="${jsonArray}" var="student">
            <tr>
                <td>${student.id}</td>
                <td>${student.name}</td>
                <td>${student.gender}</td>
                <td>${student.email}</td>
            </tr>
        </c:forEach>
    </table>
</c:if>

<c:if test="${tableName == 'teacher'}">
    <table border="1">
        <tr>
            <th>工号</th>
            <th>姓名</th>
            <th>性别</th>
            <th>邮箱</th>
            <th>所教课程</th>
        </tr>
        <c:forEach items="${jsonArray}" var="teacher">
            <tr>
                <td>${teacher.id}</td>
                <td>${teacher.name}</td>
                <td>${teacher.gender}</td>
                <td>${teacher.email}</td>
                <td>${teacher.lesson}</td>
            </tr>
        </c:forEach>
    </table>

</c:if>

<c:if test="${tableName == 'person'}">
    <table border="1">
        <tr>
            <th>工号</th>
            <th>姓名</th>
            <th>性别</th>
            <th>工作</th>
        </tr>
        <c:forEach items="${jsonArray}" var="person">
            <tr>
                <td>${person.id}</td>
                <td>${person.name}</td>
                <td>${person.gender}</td>
                <td>${person.job}</td>
            </tr>
        </c:forEach>
    </table>

</c:if>--%>
    <c:if test="${not empty tableName}">
    <div>
        <h2 align="center" style="font-family: 幼圆">
        <c:if test="${tableName == 'student'}">
            学生信息表
        </c:if>
        <c:if test="${tableName == 'person'}">
            路人信息表
        </c:if>
        <c:if test="${tableName == 'teacher'}">
            老师信息表
        </c:if>
        </h2>
    </div>

        <div>
        <table class="table table-hover table-bordered" align="center" style="font-family: 幼圆;width: 75%">

            <thead>
            <tr class="table-primary">
                <c:if test="${tableName == 'student'}">
                    <th scope="col">#</th>
                    <th scope="col">学号</th>
                    <th scope="col">姓名</th>
                    <th scope="col">性别</th>
                    <th scope="col">邮箱</th>
                </c:if>
                <c:if test="${tableName == 'teacher'}">
                    <th scope="col">#</th>
                    <th scope="col">工号</th>
                    <th scope="col">姓名</th>
                    <th scope="col">性别</th>
                    <th scope="col">邮箱</th>
                    <th scope="col">所教课程</th>
                </c:if>
                <c:if test="${tableName == 'person'}">
                    <th scope="col">#</th>
                    <th scope="col">编号</th>
                    <th scope="col">姓名</th>
                    <th scope="col">性别</th>
                    <th scope="col">工作</th>
                </c:if>

            </tr>
            </thead>
            <tbody>
            <%int count = 1;%>
            <c:forEach items="${jsonArray}" var="i">
                <tr>
                    <th scope="row"><%=count%><% count ++;%></th>
                    <td>${i.id}</td>
                    <td>${i.name}</td>
                    <td>${i.gender}</td>
                    <c:if test="${tableName == 'person'}">
                        <td>${i.job}</td>
                    </c:if>
                    <c:if test="${tableName == 'student'}">
                        <td>${i.email}</td>
                    </c:if>
                    <c:if test="${tableName == 'teacher'}">
                        <td>${i.email}</td>
                        <td>${i.lesson}</td>
                    </c:if>
                </tr>
            </c:forEach>
            </tbody>
        </table>
        </div>
    </c:if>

</body>
</html>
